package com.yan.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.connection.Message;
import org.springframework.data.redis.connection.MessageListener;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.RedisSerializer;
import org.springframework.stereotype.Service;

@Service
public class RedisMessageListeners implements MessageListener {

	@Autowired
	RedisTemplate<?, ?> redisTemplate;

	@Override
	public void onMessage(Message message, byte[] pattern) {
		String messageStr = redisTemplate.getStringSerializer().deserialize(message.getBody());
		System.err.println("message received:" + messageStr);
	}
}